﻿using System;
using System.Diagnostics.Contracts;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;

namespace Shweet.SPSolution.Shweets.ShweetsEventReciever
{
    /// <summary>
    /// List Item Events
    /// </summary>
    public class ShweetsEventReciever : SPItemEventReceiver
    {
       /// <summary>
       /// An item is being deleted.
       /// </summary>
       public override void ItemDeleting(SPItemEventProperties properties)
       {
           if (properties.UserLoginName != (string)properties.ListItem["User"])
           {
               properties.ErrorMessage = "You can't delete this";
               properties.Cancel = true;
           }
       }

    }
}
